/**
 * http-server.js
 */
const http = require("http");
const fs = require("fs");
const path = require("path");
http.createServer((req, res) => {
    if(req.method == "GET") {
        if(req.url == "/" || req.url == "/login") {
            let filePath = path.join(__dirname, "login.html");
            let fileContent = fs.readFileSync(filePath);
            res.end(fileContent);
        }
    }
    else if(req.method == "POST") {
        if(req.url == "/test") {
            let str = "";
            console.log("test1");
            req.on("data", (chunk) => {
                console.log("test");
                console.log(chunk);
                str += chunk;
            })
            req.on("end", () => {
                console.log(str);
            })
        }
    }
}).listen(8080)

console.log("server is listenin 8080")